<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/8/25 0025
 * Time: 下午 2:18
 */
namespace app\model;
class UserStudentListenComment  extends  \think\Model{

    public $table="school_student_listen_comment";

    function add_comment($params){
        $data['school_student_listen_id']=$params['school_student_listen_id'];
        $data['comment']=$params['comment'];
        $data['user_id']=$params['user_id'];
        $data['created_at']=cur_time();
        return $this->insertGetId($data);
    }

    /**
     * 根据父信息ID，返回他的下级评论
     * @param $school_student_listen_id
     * @return mixed
     */
    function get_comment_by_pid($school_student_listen_id){
        $o=$this->where(['school_student_listen_id'=>$school_student_listen_id])->order("id","desc")->select();
        $arrs=object2array($o);
        $UserResume=new UserResume();
        $SchoolStudent=new SchoolStudent();
        foreach($arrs as $k=>$v){
            $user_info=[];
            $ur_arr=$UserResume->get_head_img_name_by_user_id($v['user_id']);
            $ss_arr=$SchoolStudent->get_student($v['user_id']);
            $user_info['head_img']=$ur_arr['head_img'];
            $user_info['name']=$ss_arr['stu_name'];
            $arrs[$k]['user_info']=$user_info;
        }
        return $arrs;
    }
}